<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/resource/common.jsp"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<%--系统人员 列表 --%>
	<title>${title}</title>
	<script type="text/javascript">
		$(function(){
			//界面初始化
			$("#query_form").css({"width":$(window).width()});
			$('#test').datagrid({
				//title:'My DataGrid',
				iconCls:'icon-save',
				width:$(window).width(),
				height: $(window).height()-42,
				nowrap: true,
				//autoRowHeight: false,
				striped: true,
				singleSelect:true,
				fitColumns:true,
				//collapsible:true,
				url:'<%=path%>/user/listggo/${deptId}.json',
				//sortName: 'code',
				//sortOrder: 'desc',
				//remoteSort: false,
				idField:'',
				onLoadSuccess:function(data){
					$(this).datagrid('doCellTip',{'max-width':'300px','delay':500});
				},
				frozenColumns:[[
				]],
				columns:[
				  [	
				  	{field:'policeNum',title:'警号',width:50,align:'left',fixed:true},
				  	{field:'name',title:'姓名',width:60,align:'left',fixed:true},
			      	{field:'deptName',title:'部门',width:120,align:'left'},
			      	{field:'idCard',title:'身份证号',width:115,fixed:true,align:'center'},
			      	{field:'tel_mobile',title:'联系电话',width:120,align:'left',fixed:true},
					{field:'opt',title:'操作',width:110,fixed:true,align:'center', 
						formatter:function(value,rec){ 
			      		if(rec.policeNum!='100000'){
			      			
							return "<span style='color:red'><a href=javascript:initPwd('"+rec.policeNum+"') >重置密码  </a>"+
					   				"<a href=javascript:role_plus('"+rec.policeNum+"')   >  分配角色</a></span>";
						}
			      		else{
			      			return "<span><a style='color:#ccc;'>重置密码  </a><a style='color:#ccc;'>  分配角色</a></span>";
			      		}
			      		}
					},
				]],
				pagination:true,
				rownumbers:true,
				toolbar:[
					
				]
			});
			var p = $('#test').datagrid('getPager');
			$(p).pagination({
				onBeforeRefresh:function(){
					//alert('before refresh');
				}
			});
			
		});	
		
		
		function _goto(pageIndex){
			if($("#iscascade").attr("checked")=="checked"){
				$("#cascade").val("1");
			}else{
				$("#cascade").val("0");
			}
				$('#test').datagrid('load',{
				name:$('#name').val(),
				policeNum:$('#policeNum').val()
			});
		}
		
		
		function initPwd(policenum){
			$.messager.confirm("密码重置","是否重置用户密码？",function (r){
				if(r)
				{
					var url="<%= request.getContextPath()%>/user/resetpwd/"+policenum+".json";
					$.ajax({
						type:"post",
						dataType:"json",
						url:url,
						success:function(data){
							$.messager.show({
								title:'提示',
								msg:'密码已恢复初始',
								showType:'show',
								timeout:1000,
								style:{
									right:'',
									top:document.body.scrollTop+document.documentElement.scrollTop,
									bottom:''
								}
							});
						}
					});
				}
			})
			
			return ;
		}
		
		function role_plus(policeNum)
		{    
			var url = top.formateUrl("sys/role/pluslist/@.html").replace("@", policeNum);
			var options = {
					w:220,h:250,title:"分配角色",fn:'plusAdd',id:"user"
			}
			top.showWin(url,options)
			return ;
		    var url = "<%= request.getContextPath()%>/sys/role/pluslist/@.html".replace("@", policeNum);
			win = art.dialog.open(url, {
				title : "分配角色",
				lock : true,
				width : 200,
				height : 150,
				fixed : true,
				resize : false,
				button : [ {
					name : '保存',
					callback : function() {

						var iframe = this.iframe.contentWindow;
						if (!iframe.document.body) {
							art.dialog.tips("正在加载，请稍候...", 1500);
							return false;
						}
						iframe.plusAdd();
						return false;
					}
				} ],
				cancel : true
			});
		}
	</script>
	</head>
<body >
	<div>
		<div >
			<form id="query_form"  method="post" style="margin:0px;padding:0px;">
<table width="100%" border="0" cellspacing="0" cellpadding="4" style="background:#e9f8ff; border:1px solid #cbd9e4; font-size:14px;">
					<tr>
						<td class="td_label">警号</td>
						<td class="td_text" style="width:130px;"><input type="text" id="policeNum" name="policeNum" value="${user.policeNum}" style="width:130px;height:18px;padding:1px;" maxlength="8" onblur="this.value=this.value.replace(/[^\w\b\u4e00-\u9fa5]/g,'');"/></td>
						<td class="td_label">姓名</td>
						<td class="td_text" style="width:150px;"><input type="text" id="name" name="name" value="${user.name}" style="width:130px;height:18px;padding:1px;" maxlength="10" onblur="this.value=this.value.replace(/[^\w\b\u4e00-\u9fa5]/g,'');"/></td>
						<td class="td_label">
							<a href="javascript:_goto(1);">查询</a>
						<td>
						<td>&nbsp;</td>
						<tr>
					</tr>
					</tr>
				</table>
			</form>
		</div>
		<div id="tbl_container">
			<table id="test">
	   			
	   		</table>
	   	</div>
</body>
</html>
